package com.hjm.project.lotteryPaymentOrder.lotteryPaymentOrder.controller;

import java.util.List;
import java.util.Map;

import com.yxhd.encrypt.EncryptUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.lotteryPaymentOrder.lotteryPaymentOrder.domain.LotteryPaymentOrder;
import com.hjm.project.lotteryPaymentOrder.lotteryPaymentOrder.service.ILotteryPaymentOrderService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;
import javax.annotation.Resource;

/**
 * 彩票支付订单Controller
 * 
 * @author maker-platform
 * @date 2021-03-19
 */
@Controller
@RequestMapping("/lotteryPaymentOrder/lotteryPaymentOrder")
public class LotteryPaymentOrderController extends BaseController
{
    private String prefix = "lotteryPaymentOrder/lotteryPaymentOrder";

    @Resource
    private ILotteryPaymentOrderService lotteryPaymentOrderService;


    /**
     *  订单列表页面
     * @Param []
     * @Return java.lang.String
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:view")
    @GetMapping()
    public String lotteryPaymentOrder()
    {
        return prefix + "/lotteryPaymentOrder";
    }


    /**
     * 交易明细页面
     * @Param []
     * @Return java.lang.String
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:view")
    @GetMapping("/lotteryList")
    public String lotteryList()
    {
        return prefix + "/lotteryList";
    }

    /**
     * 清算明细页面
     * @Param []
     * @Return java.lang.String
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:view")
    @GetMapping("/auditDataList")
    public String auditDataList()
    {
        return prefix + "/auditDataList";
    }

    /**
     * 查询彩票支付订单列表
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LotteryPaymentOrder lotteryPaymentOrder) {
        startPage();
        List<LotteryPaymentOrder> list = lotteryPaymentOrderService.selectLotteryPaymentOrderList(lotteryPaymentOrder);
        return getDataTable(list);
    }


    /**
     * 查询彩票支付订单列表
     */
    @PostMapping("/list2")
    @ResponseBody
    public TableDataInfo list2(@RequestParam Map param) throws Exception {
        if (param.get("localdate3") != null && !param.get("localdate3").equals("")) {
            param.put("localdate3",param.get("localdate3") + " 00:00:00");
        }
        if (param.get("localdate4") != null && !param.get("localdate4").equals("")) {
            param.put("localdate4",param.get("localdate4") + " 23:59:59");

        }
        startPage();
        List<Map> list = lotteryPaymentOrderService.selectLotteryPaymentOrderListTwo(param);
        for (Map map : list) {
            if (map.get("LINK_PHONE") != null && !map.get("LINK_PHONE").toString().equals("")) {
                map.put("LINK_PHONE", EncryptUtils.getDecrypt(map.get("LINK_PHONE").toString()));
            }
        }
        return getDataTable(list);
    }


    /**
     * 购彩交易明细查询
     */
    @PostMapping("/getBankExList")
    @ResponseBody
    public TableDataInfo getBankExList(@RequestParam Map param) throws Exception {
        startPage();
        List<Map> list = lotteryPaymentOrderService.getBankExList(param);
        return getDataTable(list);
    }

    /**
     * 清结算明细查询
     */
    @PostMapping("/auditDataList")
    @ResponseBody
    public TableDataInfo auditDataList(@RequestParam Map param) throws Exception {
        startPage();
        List<Map> list = lotteryPaymentOrderService.getAuditDataList(param);
        return getDataTable(list);
    }

    /**
     * 导出彩票支付订单列表
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:export")
    @Log(title = "彩票支付订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LotteryPaymentOrder lotteryPaymentOrder) {
        List<LotteryPaymentOrder> list = lotteryPaymentOrderService.selectLotteryPaymentOrderList(lotteryPaymentOrder);
        ExcelUtil<LotteryPaymentOrder> util = new ExcelUtil<LotteryPaymentOrder>(LotteryPaymentOrder.class);
        return util.exportExcel(list, "lotteryPaymentOrder");
    }

    /**
     * 新增彩票支付订单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存彩票支付订单
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:add")
    @Log(title = "彩票支付订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LotteryPaymentOrder lotteryPaymentOrder)
    {
        return toAjax(lotteryPaymentOrderService.insertLotteryPaymentOrder(lotteryPaymentOrder));
    }

    /**
     * 修改彩票支付订单
     */
    @GetMapping("/edit/{serial}")
    public String edit(@PathVariable("serial") String serial, ModelMap mmap)
    {
        LotteryPaymentOrder lotteryPaymentOrder = lotteryPaymentOrderService.selectLotteryPaymentOrderById(serial);
        mmap.put("lotteryPaymentOrder", lotteryPaymentOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存彩票支付订单
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:edit")
    @Log(title = "彩票支付订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LotteryPaymentOrder lotteryPaymentOrder)
    {
        return toAjax(lotteryPaymentOrderService.updateLotteryPaymentOrder(lotteryPaymentOrder));
    }

    /**
     * 删除彩票支付订单
     */
    @RequiresPermissions("lotteryPaymentOrder:lotteryPaymentOrder:remove")
    @Log(title = "彩票支付订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(lotteryPaymentOrderService.deleteLotteryPaymentOrderByIds(ids));
    }
}
